using UnityEngine;
using System.Collections;

public class ManagerAnimation : MonoBehaviour
{
	#region Getters and Setters
	
	//Can change to other animation ?
	public bool CanChangeAnimation
	{
		get 
		{
			if(animation.clip != null)
			{
				if(animation.clip.wrapMode == WrapMode.Once)
					return !animation.isPlaying;
			}
			
			return true;
		}
	}
	
	#endregion Getters and Setters;
	
	/// <summary>
	/// Play the specified animationName.
	/// </summary>
	/// <param name='animationName'>
	/// Animation name.
	/// </param>
	public void Play(string animationName)
	{
		//If the current animation not equal of received animation...
		if(animation.clip == null || !animation.clip.name.Equals(animationName))
		{
			//If found the animation on list of animation: Update the current animation.
			if(animation.GetClip(animationName))
			{ 
				animation.clip = animation.GetClip(animationName);
				animation.Play(animationName);
			}
		}
	}
	
	/// <summary>
	/// Stop the current animation.
	/// </summary>
	public void Stop()
	{
		animation.Stop();
	}
}
